package assignment;

public class Test {
    public final static int INFINITY=Integer.MAX_VALUE;
    public static void main(String[] args)throws Exception {
        Object vexs[]={"A","B","E","G","P"};
        int index=vexs.length;
        int[][] arcs = new int[index][index];
        int[] v0 = {0,INFINITY,INFINITY,10,12};
        int[] v1 = {INFINITY,0,4,INFINITY,INFINITY};
        int[] v2 =  {INFINITY,4,0,8,INFINITY};
        int[] v3 = {10,INFINITY,8,0,INFINITY};               
        int[] v4={12,INFINITY,INFINITY,INFINITY,0};
        arcs[0] = v0;
        arcs[1] = v1;
        arcs[2] = v2;
        arcs[3] = v3;  
        arcs[4] = v4;
        MGraph G=new MGraph(GraphKind.UDG,5,4,vexs,arcs);
        ShortestPath_FLOYD floyd=new ShortestPath_FLOYD();
        floyd.floyd(G);
        print(G, floyd.getW());
        test2 t=new test2();
        t.findPlace();
        System.out.println(t.m);
    }

    public static void print(MGraph G, int[][] W) throws Exception {
        int m=0,n=0;
        for( int i=0;i<G.getVexs().length;i++){
            if(G.getVex(i)=="P")
                m=i;
            if(G.getVex(i)=="E")
                n=i;
        }
        System.out.print("最佳路径为：");
                int k=W[m][n];
                System.out.println("P-->E");
                System.out.print(G.getVex(m));
                while(k!=n){
                    System.out.print("-->"+G.getVex(k));
                    k=W[k][n];
            }
        System.out.print("-->"+G.getVex(n));
    System.out.println();
}
}
